﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Anata.AnataServerDataSetTableAdapters;

namespace Anata
{
    struct User
    {
        public static string username;
        public static int userid;
        public static int roleid;
    }

    public class _log
    {
        public string Table;
        public int RowID;
        public string Field;
        public string Qtype;
        public string Old_v;
        public string New_v;

        public _log(string table, int rowid, string field, string qtype, string old_value, string new_value)
        {
            Table = table; RowID = rowid; Field = field; Qtype = qtype; Old_v = old_value; New_v = new_value;
        }
    }

    class Log
    {
        public Log() { }

        public void ProcessLog(List<_log> list)
        {
            server_logTableAdapter Adapter = new server_logTableAdapter();
            DateTime now = DateTime.Now;

            foreach (_log l in list)
            {
                try
                {
                    Adapter.Insert(User.userid, l.Qtype, l.Table, l.RowID, l.Field, l.Old_v, l.New_v, now);
                }
                catch (Exception e) { throw e; }
            }
        }
    }
}
